package logique.administration;

import java.util.ArrayList;

import controleur.Controleur;

/**
 * 
 * @author camille
 *
 */
public class Administration {

	private Controleur controleur;
	private ArrayList<Modification> modifications;

	public Administration(Controleur controleur) {
		this.controleur = controleur;
		this.modifications = new ArrayList<Modification>();
	}

	public synchronized ArrayList<Modification> getModifications() {
		return this.modifications;
	}
	
	public synchronized boolean isEmpty(){
		return this.modifications.isEmpty();
	}

	public synchronized void ajoutModification(Modification modification) {
		modifications.add(modification);
	}

	public synchronized void suppressionModification(int id) {
		modifications.remove(id);
	}

	public synchronized void changerModification(int id, Modification nModification) {
		modifications.remove(id);
		modifications.add(id, nModification);
	}

	public synchronized void valideModifications() {
		if (controleur != null) {
			controleur.maj();
		}
	}
}
